package com.ego.controller;

import com.ego.commons.pojo.EasyUITree;
import com.ego.commons.pojo.EgoResult;
import com.ego.pojo.TbContentCategory;
import com.ego.service.TBContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TBContentCategoryController {

    @Autowired
    private TBContentCategoryService tbContentCategoryService;

    @RequestMapping("/content/category/list")
    public List<EasyUITree> contentCatgoryList(@RequestParam(defaultValue = "0") long id){
        return tbContentCategoryService.selectContentCategoryByParentId(id);
    }


    @PostMapping("/content/category/create")
    public EgoResult create(TbContentCategory tbContentCategory){

        return  tbContentCategoryService.insert(tbContentCategory);
    }


    @PostMapping("/content/category/update")
    public EgoResult update(TbContentCategory tbContentCategory){

        return  tbContentCategoryService.update(tbContentCategory);
    }


    @PostMapping("/content/category/delete/")
    public EgoResult delete(long id){
        return tbContentCategoryService.delete(id);
    }

}
